import 'dart:convert' show json;

class NovelSearch {
  int code;
  String msg;
  Data data;

  NovelSearch.fromParams({this.code, this.msg, this.data});

  factory NovelSearch(jsonStr) => jsonStr == null
      ? null
      : jsonStr is String
          ? new NovelSearch.fromJson(json.decode(jsonStr))
          : new NovelSearch.fromJson(jsonStr);

  NovelSearch.fromJson(jsonRes) {
    code = jsonRes['code'];
    msg = jsonRes['msg'];
    data = jsonRes['data'] == null ? null : new Data.fromJson(jsonRes['data']);
  }

  @override
  String toString() {
    return '{"code": $code,"msg": ${msg != null ? '${json.encode(msg)}' : 'null'},"data": $data}';
  }
}

class Data {
  int status;
  List<Relate> data;
  Result aladdin;
  Info info;
  Spend spend;

  Data.fromParams(
      {this.status, this.data, this.aladdin, this.info, this.spend});

  Data.fromJson(jsonRes) {
    status = jsonRes['status'];
    data = jsonRes['data'] == null ? null : [];

    for (var dataItem in data == null ? [] : jsonRes['data']) {
      data.add(dataItem == null ? null : new Relate.fromJson(dataItem));
    }

    aladdin = jsonRes['aladdin'] == null
        ? null
        : new Result.fromJson(jsonRes['aladdin']);
    info = jsonRes['info'] == null ? null : new Info.fromJson(jsonRes['info']);
    spend =
        jsonRes['spend'] == null ? null : new Spend.fromJson(jsonRes['spend']);
  }

  @override
  String toString() {
    return '{"status": $status,"data": $data,"aladdin": $aladdin,"info": $info,"spend": $spend}';
  }
}

class Spend {
  double total;

  Spend.fromParams({this.total});

  Spend.fromJson(jsonRes) {
    total = jsonRes['total'];
  }

  @override
  String toString() {
    return '{"total": $total}';
  }
}

class Info {
  int count;
  int page;
  int size;
  int total;
  String qp_rewrite;
  String qp_trigger;

  Info.fromParams(
      {this.count,
      this.page,
      this.size,
      this.total,
      this.qp_rewrite,
      this.qp_trigger});

  Info.fromJson(jsonRes) {
    count = jsonRes['count'];
    page = jsonRes['page'];
    size = jsonRes['size'];
    total = jsonRes['total'];
    qp_rewrite = jsonRes['qp_rewrite'];
    qp_trigger = jsonRes['qp_trigger'];
  }

  @override
  String toString() {
    return '{"count": $count,"page": $page,"size": $size,"total": $total,"qp_rewrite": ${qp_rewrite != null ? '${json.encode(qp_rewrite)}' : 'null'},"qp_trigger": ${qp_trigger != null ? '${json.encode(qp_trigger)}' : 'null'}}';
  }
}

class Result {
  int authorid;
  int base;
  int bid;
  int formats;
  int hh_hot;
  int mgbid;
  int status;
  int words;
  String author;
  String category;
  String cover;
  String desc;
  String host;
  String tags;
  String title;
  String top_class;
  FirstChapter first_chapter;
  LatestChapter latest_chapter;

  Result.fromParams(
      {this.authorid,
      this.base,
      this.bid,
      this.formats,
      this.hh_hot,
      this.mgbid,
      this.status,
      this.words,
      this.author,
      this.category,
      this.cover,
      this.desc,
      this.host,
      this.tags,
      this.title,
      this.top_class,
      this.first_chapter,
      this.latest_chapter});

  Result.fromJson(jsonRes) {
    authorid = jsonRes['authorid'];
    base = jsonRes['base'];
    bid = jsonRes['bid'];
    formats = jsonRes['formats'];
    hh_hot = jsonRes['hh_hot'];
    mgbid = jsonRes['mgbid'];
    status = jsonRes['status'];
    words = jsonRes['words'];
    author = jsonRes['author'];
    category = jsonRes['category'];
    cover = jsonRes['cover'];
    desc = jsonRes['desc'];
    host = jsonRes['host'];
    tags = jsonRes['tags'];
    title = jsonRes['title'];
    top_class = jsonRes['top_class'];
    first_chapter = jsonRes['first_chapter'] == null
        ? null
        : new FirstChapter.fromJson(jsonRes['first_chapter']);
    latest_chapter = jsonRes['latest_chapter'] == null
        ? null
        : new LatestChapter.fromJson(jsonRes['latest_chapter']);
  }

  @override
  String toString() {
    return '{"authorid": ${author != null ? '${json.encode(author)}' : 'null'}id,"base": $base,"bid": $bid,"formats": $formats,"hh_hot": $hh_hot,"mgbid": $mgbid,"status": $status,"words": $words,"author": ${author != null ? '${json.encode(author)}' : 'null'},"category": ${category != null ? '${json.encode(category)}' : 'null'},"cover": ${cover != null ? '${json.encode(cover)}' : 'null'},"desc": ${desc != null ? '${json.encode(desc)}' : 'null'},"host": ${host != null ? '${json.encode(host)}' : 'null'},"tags": ${tags != null ? '${json.encode(tags)}' : 'null'},"title": ${title != null ? '${json.encode(title)}' : 'null'},"top_class": ${top_class != null ? '${json.encode(top_class)}' : 'null'},"first_chapter": $first_chapter,"latest_chapter": $latest_chapter}';
  }
}

class LatestChapter {
  int ctime;
  String cid;
  String cname;

  LatestChapter.fromParams({this.ctime, this.cid, this.cname});

  LatestChapter.fromJson(jsonRes) {
    ctime = jsonRes['ctime'];
    cid = jsonRes['cid'];
    cname = jsonRes['cname'];
  }

  @override
  String toString() {
    return '{"ctime": $ctime,"cid": ${cid != null ? '${json.encode(cid)}' : 'null'},"cname": ${cname != null ? '${json.encode(cname)}' : 'null'}}';
  }
}

class FirstChapter {
  int ctime;
  String cid;
  String cname;

  FirstChapter.fromParams({this.ctime, this.cid, this.cname});

  FirstChapter.fromJson(jsonRes) {
    ctime = jsonRes['ctime'];
    cid = jsonRes['cid'];
    cname = jsonRes['cname'];
  }

  @override
  String toString() {
    return '{"ctime": $ctime,"cid": ${cid != null ? '${json.encode(cid)}' : 'null'},"cname": ${cname != null ? '${json.encode(cname)}' : 'null'}}';
  }
}

class Relate {
  int authorid;
  int base;
  int bid;
  int first_cid;
  int formats;
  int hh_hot;
  int mgbid;
  int status;
  int words;
  String author;
  String category;
  String cover;
  String desc;
  String first_chapter;
  String host;
  String tags;
  String title;
  String top_class;

  Relate.fromParams(
      {this.authorid,
      this.base,
      this.bid,
      this.first_cid,
      this.formats,
      this.hh_hot,
      this.mgbid,
      this.status,
      this.words,
      this.author,
      this.category,
      this.cover,
      this.desc,
      this.first_chapter,
      this.host,
      this.tags,
      this.title,
      this.top_class});

  Relate.fromJson(jsonRes) {
    authorid = jsonRes['authorid'];
    base = jsonRes['base'];
    bid = jsonRes['bid'];
    first_cid = jsonRes['first_cid'];
    formats = jsonRes['formats'];
    hh_hot = jsonRes['hh_hot'];
    mgbid = jsonRes['mgbid'];
    status = jsonRes['status'];
    words = jsonRes['words'];
    author = jsonRes['author'];
    category = jsonRes['category'];
    cover = jsonRes['cover'];
    desc = jsonRes['desc'];
    first_chapter = jsonRes['first_chapter'];
    host = jsonRes['host'];
    tags = jsonRes['tags'];
    title = jsonRes['title'];
    top_class = jsonRes['top_class'];
  }

  @override
  String toString() {
    return '{"authorid": ${author != null ? '${json.encode(author)}' : 'null'}id,"base": $base,"bid": $bid,"first_cid": $first_cid,"formats": $formats,"hh_hot": $hh_hot,"mgbid": $mgbid,"status": $status,"words": $words,"author": ${author != null ? '${json.encode(author)}' : 'null'},"category": ${category != null ? '${json.encode(category)}' : 'null'},"cover": ${cover != null ? '${json.encode(cover)}' : 'null'},"desc": ${desc != null ? '${json.encode(desc)}' : 'null'},"first_chapter": ${first_chapter != null ? '${json.encode(first_chapter)}' : 'null'},"host": ${host != null ? '${json.encode(host)}' : 'null'},"tags": ${tags != null ? '${json.encode(tags)}' : 'null'},"title": ${title != null ? '${json.encode(title)}' : 'null'},"top_class": ${top_class != null ? '${json.encode(top_class)}' : 'null'}}';
  }
}
